var mysql = require('mysql');

module.exports = {
    // 连接数据库
    connect: function() {
        this.connection = mysql.createConnection({     
          host     : 'localhost',       
          user     : 'root',              
          password : 'xuanyi',       
          port: '3306',                   
          database: 'waige' 
        });
        this.connection.connect();
    },


    // 关闭数据库
    disconnect: function() {
        this.connection.end();
    },


    // 查询
    select: function(sql, cb) {
        this.connection.query(sql, function (err, result) {
            cb(err, result);
        });
    }

};